import requests

# 1. 登录
my_session = requests.session()  # 会话：一连串请求
url = "https://passport.17k.com/ck/user/login"
resp = my_session.post(url, data={'loginName': '18117083808', 'password': '987654a*'})
# print(resp.text)
print(resp.cookies)

# 2. 拿数据
url = "https://user.17k.com/ck/author/shelf"
resp = my_session.get(url)
print(resp.json())

# 也可以直接这样做：
'''
print(
    requests.get(
        url="https://user.17k.com/ck/author/shelf",
        headers={
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
            'Cookie': 'GUID=351c3e45-bd83-4862-92d3-4354341daa28; BAIDU_SSP_lcr=http://www.hao123.com/link/v3/?key=pZwYTjCEQLILIz3kPv_8mvqVQs%3D%3D&pageid=hao123-pcbdhz-book&monkey=m-pcbdhz-book&title=17k1658465491830; sajssdk_2015_cross_new_user=1; Hm_lvt_9793f42b498361373512340937deb2a0=1658465514; _openId=ow-yN5vcM6ACzp7cHK2wfeg4iFmU; c_channel=0; c_csc=web; accessToken=avatarUrl%3Dhttps%253A%252F%252Fcdn.static.17k.com%252Fuser%252Favatar%252F05%252F65%252F02%252F97450265.jpg-88x88%253Fv%253D1658466065000%26id%3D97450265%26nickname%3Dsdgbnhnsgbsfsbhl%26e%3D1674018345%26s%3D7d58c512b4155ed6; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2297450265%22%2C%22%24device_id%22%3A%22182243f706c360-08253ebb3d864b-3e604809-2073600-182243f706d4cb%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%2C%22first_id%22%3A%22351c3e45-bd83-4862-92d3-4354341daa28%22%7D; Hm_lpvt_9793f42b498361373512340937deb2a0=1658466825'
        }
    ).text
)
'''
